
<h1><span class="yiyi-st" id="yiyi-13">numpy.core.defchararray.chararray.flat</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.core.defchararray.chararray.flat.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.core.defchararray.chararray.flat.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="attribute">
<dt id="numpy.core.defchararray.chararray.flat"><span class="yiyi-st" id="yiyi-14"> <code class="descclassname">chararray.</code><code class="descname">flat</code></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-15">数组上的1-D迭代器。</span></p>
<p><span class="yiyi-st" id="yiyi-16">这是一个<a class="reference internal" href="numpy.flatiter.html#numpy.flatiter" title="numpy.flatiter"><code class="xref py py-obj docutils literal"><span class="pre">numpy.flatiter</span></code></a>实例，它类似于Python的内置迭代器对象，但不是其子类。</span></p>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-17">也可以看看</span></p>
<dl class="docutils">
<dt><span class="yiyi-st" id="yiyi-18"><a class="reference internal" href="numpy.core.defchararray.chararray.flatten.html#numpy.core.defchararray.chararray.flatten" title="numpy.core.defchararray.chararray.flatten"><code class="xref py py-obj docutils literal"><span class="pre">flatten</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-19">将折叠的数组的副本返回到一个维度。</span></dd>
</dl>
<p class="last"><span class="yiyi-st" id="yiyi-20"><code class="xref py py-obj docutils literal"><span class="pre">flatiter</span></code></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-21">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span>
<span class="go">array([[1, 2, 3],</span>
<span class="go">       [4, 5, 6]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">flat</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
<span class="go">4</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">T</span>
<span class="go">array([[1, 4],</span>
<span class="go">       [2, 5],</span>
<span class="go">       [3, 6]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">flat</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
<span class="go">5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">type</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">flat</span><span class="p">)</span>
<span class="go">&lt;type &apos;numpy.flatiter&apos;&gt;</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-22">分配示例：</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">flat</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span> <span class="n">x</span>
<span class="go">array([[3, 3, 3],</span>
<span class="go">       [3, 3, 3]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">.</span><span class="n">flat</span><span class="p">[[</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">x</span>
<span class="go">array([[3, 1, 3],</span>
<span class="go">       [3, 1, 3]])</span>
</pre></div>
</div>
</dd></dl>
